<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>找出数组里最大的素数</title>
</head>

<body>
  <script>
    var arr = [1, 3, 5, 7];
    for (var i = 1; i < arr.length; i++) {
      var flag = 1;
      for (var j = 2; j < i; j++) {
        if (arr[i] % arr[j] == 0) {
          flag = 0;
          break;
        }
      }

      max = arr[0]
      if (flag) {
        if (arr[i] > max) {
          max = arr[i]
        }
      }
      console.log(arr[i])
    }
    console.log(max);

  </script>
</body>

</html>